package com.class04.stream;

import com.class04.reference.data.Employee;
import com.class04.reference.data.EmployeeData;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/11/29 20:05
 */
public class StreamAPITest {
    @Test
    public void test1(){
//        创建Stream方式一：通过集合
        List<Employee> employees = EmployeeData.getEmployees();
//        返回一个顺序流 default Stream<E> stream();
        Stream<Employee> stream = employees.stream();
        stream.forEach(System.out::println);
        System.out.println("stream = " + stream);
    }
    //    创建 Stream方式二：通过数组
    public void test2(){
        Integer[] arr = new Integer[]{1,2,3,4,5,6};
        Stream<Integer> stream = Arrays.stream(arr);


    }
//    创建Stream方式三：通过Stream的of()
    public void test3(){
        Stream.of("AA", "BB", "CC");
    }


}
